package org.fuys.coder.domain.audit.service.policy.result.impl;

import org.fuys.coder.domain.audit.model.req.AuditTask;
import org.fuys.coder.domain.audit.model.res.AuditResult;
import org.fuys.coder.domain.audit.model.vo.AuditTaskIdTypeVO;
import org.fuys.coder.domain.audit.respository.IAuditFailedRepository;
import org.fuys.coder.domain.audit.service.policy.result.AuditResultStrategy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @projectName: fuys-low-coder
 * @package: org.fuys.coder.domain.audit.service.policy.result.impl
 * @className: BlockStrategy
 * @author: WangJing
 * @description: 审核推荐拦截策略
 * @date: 2024/6/22 17:37
 * @version: 1.0
 */
@Service("blockStrategy")
public class BlockStrategy implements AuditResultStrategy {

    @Resource
    private IAuditFailedRepository auditFailedRepository;

    @Override
    public void handleResult(AuditResult auditResult, AuditTask task) {
        //确保审核任务完成
        if(auditResult.isFinish()){
            //虽然审核成功之后是人生有梦各自精彩 但是审核失败考虑的就很少了 直接打入大牢
            //这里保证成功之后 将发送信息给用户收件箱 但是收件箱要和推送一起进行
            //TODO 收件箱完成设置
            auditFailedRepository.saveRecord(task.getIdType(),task.getOtherId(),
                    task.getUserId(),auditResult.getMsg());
        }
    }
}
